<!DOCTYPE html>
<#assign ctx=Session.basePath>
<html>
<head>
    <meta http-equiv="refresh" content="text/html; charset=utf-8" />
    <title>自有船舶</title>
    <script>
        var shipid = '<#if shipid??>${shipid}<#else></#if>';
        var company =  '<#if company??>${company}<#else></#if>';
    </script>
    <link href="${ctx}/easyui/themes/bootstrap/easyui.css" rel="stylesheet" />
    <link href="${ctx}/easyui/themes/icon.css" rel="stylesheet" />
    <link href="${ctx}/inspiniain/font-awesome/css/font-awesome.css" rel="stylesheet">
    <script src="${ctx}/easyui/jquery.easyui.min.js"></script>
    <script src="${ctx}/easyui/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript">
        function loadAll(){

            var pager = $('#dg').datagrid({
                fitColumns:true,
                fit: true,
                loadFilter: function(data){
                    if(data != null && data.rows != null){
                        for(var i = 0; i < data.rows.length; i++){
                            var record = data.rows[i];
                            var shipName;
                            if(record.shipname!=null){
                                shipName = record.shipname;
                            }
                            var longitude =record.lon;
                            var latitude =record.lat;
                            var shipimei=record.shipimei;
                            var course=record.course;
                            var position = "<a href='#' onclick='locBoat(\""+longitude+"\",\""+latitude+"\")'>"+shipName+"</a>";
                            var track = "<a href='#' onclick='locationMap(\""+longitude+"\",\""+latitude+"\",\""+shipimei+"\",\""+shipName+"\",\""+course+"\")'><i class='fa fa-eye'></i></a>";
                            record.position = position;
                            record.track = track;
                        }
                    }
                    return data;
                }
            });

            var page=$('#dg').datagrid('getPager');
            page.pagination({
                layout:['first','prev','next','last','refresh'],
                showRefresh:true
            });
        }

        function  locBoat(lon,lat){
            if(lon!='null'&&lat!='null')
            {
                window.parent.locBoat(lon,lat);
            }else{
                window.parent.layer.alert('无法追踪该船舶');
            }
        }


        function locationMap(lon,lat,shipimei,shipname,course) {
            if(lon!='null'&&lat!='null')
            {
                var trackShip={
                    trackId:shipimei,
                    type:"cyx"
                }
                window.parent.locMap(lon,lat,trackShip,shipname,course);
            }else{
                window.parent.layer.alert('无法追踪该船舶');
            }

        }
        $(function () {
            loadAll();

        })
    </script>
</head>
<body>
<table id="dg",
       data-options="rownumbers:false,singleSelect:true,pagination:true,url:'${ctx}/manage/map/company/cyxShip/ajax/list',method:'post',toolbar:'#tb'">
    <thead>
    <tr>
        <th data-options="field:'position',width:100">船舶名称</th>
        <th data-options="field:'mmsi',width:100,align:'center'">MMSI</th>
        <th data-options="field:'track',width:40,align:'center'">追踪</th>
    </tr>
    </thead>
</table>
</body>
</html>